var tuiwa = require("../../tuiwa.js")

var lasttime = 0;
const app = getApp()

Page({
  data: {
    timu: [],
    testResultBg: "",
    title: "",
    testResultList: [],
    progress: 0,
    id: null,
    lookResultLayer: false,
    choiceArray: [],
    multipleChoiceArr: [],
    cunwanAnswer: [],
    authenticAnswers: []
  },
  onLoad: function (options) {

    wx.setNavigationBarTitle({
      title: options.title
    })
    this.setData({
      multiple: options.multiple,
      title: options.title,
      testResultBg: options.testResultBg,
      timu: JSON.parse(options.timu),
      testResultList: JSON.parse(options.testResultList),
    })
    tt.getSystemInfo({
      success: (res) => {
        if (res.platform == "ios" && res.version >= "10.7" && res.appName == "Douyin" || res.platform == "android" && res.system >= "10.3" && res.appName == "Douyin") {
          tuiwa.globalData.currentPage = this
        }
      }
    })
  },
  itemClick(e) {
    let d = new Date();
    let nowtime = d.getTime();
    if (nowtime - lasttime > 1500) {
      var index = e.currentTarget.dataset.index
      var indexArr = this.data.choiceArray
      indexArr.push(index)

      this.setData({
        id: index,
        choiceArray: indexArr // choiceArray用来存放选择的选项
      })
      console.log(this.data.choiceArray)

      if ((this.data.progress + 1) == this.data.timu.length) {
        this.setData({
          lookResultLayer: true
        })
        return
      }
      setTimeout(() => {
        this.setData({
          id: null,
          progress: this.data.progress + 1
        })
      }, 1000)

      lasttime = nowtime;
    }
  },
  backPreviousQuestionClick() {
    let d = new Date();
    let nowtime = d.getTime();
    if (nowtime - lasttime > 1500) {
      this.data.choiceArray.pop()
      setTimeout(() => {
        this.setData({
          id: null,
          progress: this.data.progress - 1
        })
      }, 500)

      lasttime = nowtime;
    }
    console.log("choiceArray:", this.data.choiceArray)
  },
  itemMultipleClick(e) {
    let d = new Date();
    let nowtime = d.getTime();
    if (nowtime - lasttime > 1500) {

      var index = e.currentTarget.dataset.index
      console.log("index的值是：", index)
      console.log(this.data.progress)
      var item = this.data.timu[this.data.progress].options[index]
      item.flag1 = !item.flag1

      var multipleChoiceArr = this.data.multipleChoiceArr
      if (item.flag1) {
        multipleChoiceArr.push(index)
      } else {
        multipleChoiceArr.splice(index, 1)
      }

      this.setData({
        timu: this.data.timu,
        multipleChoiceArr
      })
      console.log("multipleChoiceArr的值是1111:", this.data.multipleChoiceArr)
      lasttime = nowtime;
    }
  },
  answerNextQuestionClick() {
    let d = new Date();
    let nowtime = d.getTime();
    if (nowtime - lasttime > 1500) {
      if ((this.data.progress + 1) == this.data.timu.length) {
        setTimeout(() => {
          this.setData({
            lookResultLayer: true
          })
        }, 500)
        return
      }
      setTimeout(() => {
        this.setData({
          progress: this.data.progress + 1
        })
      }, 1000)

      lasttime = nowtime;
    }
  },
  lookResultClick() {
    console.log(this.data.title)
    console.log("单选:", this.data.choiceArray)

    console.log(this.data.testResultList)

    if (this.data.title == "2021你的精神图腾是什么？") {
      if (this.data.choiceArray[0] === 0) {
        this.setData({
          imgUrl: this.data.testResultList[0].imgUrl
        })
      } else if (this.data.choiceArray[0] === 1) {
        this.setData({
          imgUrl: this.data.testResultList[1].imgUrl
        })
      } else if (this.data.choiceArray[0] === 2) {
        this.setData({
          imgUrl: this.data.testResultList[2].imgUrl
        })
      } else if (this.data.choiceArray[0] === 3) {
        this.setData({
          imgUrl: this.data.testResultList[3].imgUrl
        })
      } else if (this.data.choiceArray[0] === 4) {
        this.setData({
          imgUrl: this.data.testResultList[4].imgUrl
        })
      }
      tt.redirectTo({
        url: `/pages/testResult/testResult?imgUrl=${this.data.imgUrl}&testResultBg=${this.data.testResultBg}&title=${this.data.title}`
      });
    } else if (this.data.title == "2021年你会发生的5件事？") {
      if (this.data.choiceArray[3] === 0) {
        this.setData({
          imgUrl: this.data.testResultList[3].imgUrl
        })
      } else if (this.data.choiceArray[3] === 2) {
        this.setData({
          imgUrl: this.data.testResultList[4].imgUrl
        })
      } else if (this.data.choiceArray[3] === 1) {
        this.setData({
          imgUrl: this.data.testResultList[1].imgUrl
        })
      } else if (this.data.choiceArray[5] === 1) {
        this.setData({
          imgUrl: this.data.testResultList[2].imgUrl
        })
      } else if (this.data.choiceArray[5] === 0) {
        this.setData({
          imgUrl: this.data.testResultList[0].imgUrl
        })
      }
      tt.redirectTo({
        url: `/pages/testResult/testResult?imgUrl=${this.data.imgUrl}&testResultBg=${this.data.testResultBg}&title=${this.data.title}`
      });
    }
    else if (this.data.title == "2021你会以什么方式陪父母？" || this.data.title == "2021有多少人关心你？") {
      if (this.data.choiceArray[2] == 0) {
        this.setData({
          imgUrl: this.data.testResultList[0].imgUrl
        })
      } else if (this.data.choiceArray[2] == 1) {
        this.setData({
          imgUrl: this.data.testResultList[1].imgUrl
        })
      } else if (this.data.choiceArray[2] == 2) {
        this.setData({
          imgUrl: this.data.testResultList[2].imgUrl
        })
      } else if (this.data.choiceArray[2] == 3) {
        this.setData({
          imgUrl: this.data.testResultList[2].imgUrl
        })
      }
      tt.redirectTo({
        url: `/pages/testResult/testResult?imgUrl=${this.data.imgUrl}&testResultBg=${this.data.testResultBg}&title=${this.data.title}`
      });
    } else if (this.data.title == "2021正能量测试") {
      var sum = 0;
      this.data.choiceArray.forEach((item, index) => {
        if (item == 0) {
          item = 2
        } else if (item == 1) {
          item = 1
        } else if (item == 2) {
          item = 0
        }
        sum += item;
      })
      console.log("正能量测试:", sum)

      if (sum >= 12 && sum <= 16) {
        this.setData({
          imgUrl: this.data.testResultList[0].imgUrl
        })
      } else if (sum >= 6 && sum <= 11) {
        this.setData({
          imgUrl: this.data.testResultList[1].imgUrl
        })
      } else if (sum >= 0 && sum <= 5) {
        this.setData({
          imgUrl: this.data.testResultList[2].imgUrl
        })
      }
      tt.redirectTo({
        url: `/pages/testResult/testResult?imgUrl=${this.data.imgUrl}&testResultBg=${this.data.testResultBg}&title=${this.data.title}`
      })
    } else if (this.data.title == "2021春晚测试") {
      console.log(this.data.timu)
      this.data.choiceArray.forEach((item, index) => {
        var timu = this.data.timu[index]
        let wenti = timu.options[item]
        console.log("timu:", timu)
        console.log("wenti:", wenti)
        var trueAnswers = this.data.cunwanAnswer
        trueAnswers.push(wenti.flag)
        this.setData({
          cunwanAnswer: trueAnswers
        })
      })
      var trues = this.data.authenticAnswers
      this.data.cunwanAnswer.forEach((v, i) => {
        if (v) {
          trues.push(v)
        }
      })
      this.setData({
        authenticAnswers: trues
      })
      if (this.data.authenticAnswers.length >= 0 && this.data.authenticAnswers.length <= 3) {
        this.setData({
          imgUrl: this.data.testResultList[0].imgUrl
        })
      } else if (this.data.authenticAnswers.length >= 4 && this.data.authenticAnswers.length <= 6) {
        this.setData({
          imgUrl: this.data.testResultList[1].imgUrl
        })
      } else if (this.data.authenticAnswers.length == 7) {
        this.setData({
          imgUrl: this.data.testResultList[2].imgUrl
        })
      }

      tt.redirectTo({
        url: `/pages/testResult/testResult?imgUrl=${this.data.imgUrl}&testResultBg=${this.data.testResultBg}&title=${this.data.title}`
      })
    } else if (this.data.title == "智商测试题") {
      var sum1 = 0;
      this.data.choiceArray.forEach((item, index) => {
        if (index >= 0 && index <= 3) {
          var timu = this.data.timu[index]
          let wenti = timu.options[item];
          if (wenti.flag) {
            sum1 += 4;
          }
        } else if (index >= 4 && index <= 7) {
          var timu = this.data.timu[index]
          let wenti = timu.options[item];
          if (wenti.flag) {
            sum1 += 5;
          }
        } else if (index == 8) {
          var timu = this.data.timu[index + 1]
          let wenti = timu.options[item];
          if (wenti.flag) {
            sum1 += 8;
          }
        }
      })
      console.log("sum1的值是:", sum1)

      var sum2 = 0
      var trueAnswers = []
      this.data.timu.forEach((item, index) => {
        if (index == 8) {
          item.options.forEach((v, i) => {
            if (v.leap == "A" && v.flag == true) {
              trueAnswers.push(0)
            } else if (v.leap == "B" && v.flag == true) {
              trueAnswers.push(1)
            } else if (v.leap == "C" && v.flag == true) {
              trueAnswers.push(2)
            } else if (v.leap == "D" && v.flag == true) {
              trueAnswers.push(3)
            }
          })
        }
      })
      if (trueAnswers.sort().toString() == this.data.multipleChoiceArr.sort().toString()) {
        sum2 += 8
      } else {
        sum2 += 0
      }
      console.log("sum2的值是：", sum2)

      var sums = sum1 + sum2
      console.log("sums总的值是：", sums)
      tt.redirectTo({
        url: `/pages/testResult/testResult?sums=${sums}&testResultBg=${this.data.testResultBg}&title=${this.data.title}`
      });

    } else if (this.data.title == "情商测试题") {
      var sums = 0;
      if (this.data.choiceArray[0] == 0 || this.data.choiceArray[0] == 1 || this.data.choiceArray[0] == 2) {
        sums += 20
      } else if (this.data.choiceArray[0] == 3) {
        sums += 0
      }
      if (this.data.choiceArray[1] == 0 || this.data.choiceArray[1] == 2 || this.data.choiceArray[1] == 3) {
        sums += 20
      } else if (this.data.choiceArray[1] == 1) {
        sums += 0
      }
      if (this.data.choiceArray[2] == 0 || this.data.choiceArray[2] == 2) {
        sums += 20
      } else if (this.data.choiceArray[2] == 1 || this.data.choiceArray[2] == 3) {
        sums += 0
      }
      if (this.data.choiceArray[3] == 0 || this.data.choiceArray[3] == 1 || this.data.choiceArray[3] == 3) {
        sums += 0
      } else if (this.data.choiceArray[3] == 2) {
        sums += 20
      }
      if (this.data.choiceArray[4] == 0 || this.data.choiceArray[4] == 1 || this.data.choiceArray[4] == 3) {
        sums += 0
      } else if (this.data.choiceArray[4] == 2) {
        sums += 20
      }
      if (this.data.choiceArray[5] == 0) {
        sums += 0
      } else if (this.data.choiceArray[5] == 1 || this.data.choiceArray[5] == 2) {
        sums += 5
      } else if (this.data.choiceArray[5] == 3) {
        sums += 20
      }
      if (this.data.choiceArray[6] == 1 || this.data.choiceArray[6] == 2 || this.data.choiceArray[6] == 3) {
        sums += 0
      } else if (this.data.choiceArray[6] == 0) {
        sums += 20
      }
      if (this.data.choiceArray[7] == 0 || this.data.choiceArray[7] == 2 || this.data.choiceArray[7] == 3) {
        sums += 0
      } else if (this.data.choiceArray[7] == 1) {
        sums += 20
      }
      if (this.data.choiceArray[8] == 0 || this.data.choiceArray[8] == 2) {
        sums += 0
      } else if (this.data.choiceArray[8] == 1) {
        sums += 5
      } else if (this.data.choiceArray[8] == 3) {
        sums += 20
      }
      if (this.data.choiceArray[9] == 0 || this.data.choiceArray[9] == 2 || this.data.choiceArray[9] == 3) {
        sums += 0
      } else if (this.data.choiceArray[9] == 1) {
        sums += 20
      }
      console.log("sums的值是:", sums)

      tt.redirectTo({
        url: `/pages/testResult/testResult?sums=${sums}&testResultBg=${this.data.testResultBg}&title=${this.data.title}`
      });

    } else if (this.data.title == "你会遇到白月光还是朱砂痣") {
      tt.redirectTo({
        url: `/pages/testResult/testResult?title=${this.data.title}&choiceArray=${JSON.stringify(this.data.choiceArray)}`
      });
    } else if (this.data.title == "气氛组达人") {
      if (this.data.choiceArray[2] == 0) {
        this.setData({
          imgUrl: this.data.testResultList[2].imgUrl
        })
      } else if (this.data.choiceArray[2] == 1) {
        this.setData({
          imgUrl: this.data.testResultList[0].imgUrl
        })
      } else if (this.data.choiceArray[2] == 2) {
        this.setData({
          imgUrl: this.data.testResultList[1].imgUrl
        })
      }
      tt.redirectTo({
        url: `/pages/testResult/testResult?imgUrl=${this.data.imgUrl}&testResultBg=${this.data.testResultBg}&title=${this.data.title}`
      })
    } else if (this.data.title == "你适合养哪种猫主子") {
      var sum = 0;
      this.data.choiceArray.forEach((item, index) => {
        if (item == 0) {
          sum += 10
        } else if (item == 1) {
          sum += 20
        } else if (item == 2) {
          sum += 30
        } else if (item == 3) {
          sum += 40
        }
      })
      if (sum >= 60 && sum <= 90) { //橘猫
        this.setData({
          imgUrl: this.data.testResultList[1].imgUrl
        })
      } else if (sum >= 100 && sum <= 130) { //美国短毛猫
        this.setData({
          imgUrl: this.data.testResultList[2].imgUrl
        })
      } else if (sum >= 140 && sum <= 170) { //英国短毛猫
        this.setData({
          imgUrl: this.data.testResultList[4].imgUrl
        })
      } else if (sum >= 180 && sum <= 210) { //暹罗猫
        this.setData({
          imgUrl: this.data.testResultList[3].imgUrl
        })
      } else if (sum >= 220 && sum <= 240) { //布偶猫
        this.setData({
          imgUrl: this.data.testResultList[0].imgUrl
        })
      }
      tt.redirectTo({
        url: `/pages/testResult/testResult?imgUrl=${this.data.imgUrl}&title=${this.data.title}`
      })
    } else if (this.data.title == "你适合养哪种二狗子") {
      var sum = 0;
      this.data.choiceArray.forEach((item, index) => {
        if (item == 0) {
          sum += 10
        } else if (item == 1) {
          sum += 20
        } else if (item == 2) {
          sum += 30
        } else if (item == 3) {
          sum += 40
        }
      })
      if (sum >= 60 && sum <= 90) { //金毛
        this.setData({
          imgUrl: this.data.testResultList[3].imgUrl
        })
      } else if (sum >= 100 && sum <= 130) { //德国牧羊犬
        this.setData({
          imgUrl: this.data.testResultList[1].imgUrl
        })
      } else if (sum >= 140 && sum <= 170) { //萨摩耶
        this.setData({
          imgUrl: this.data.testResultList[4].imgUrl
        })
      } else if (sum >= 180 && sum <= 210) { //阿拉斯加雪橇犬
        this.setData({
          imgUrl: this.data.testResultList[0].imgUrl
        })
      } else if (sum >= 220 && sum <= 240) { //哈士奇
        this.setData({
          imgUrl: this.data.testResultList[2].imgUrl
        })
      }
      tt.redirectTo({
        url: `/pages/testResult/testResult?imgUrl=${this.data.imgUrl}&title=${this.data.title}`
      })
    } else if (this.data.title == "2021你最适合做哪种投资") {
      if (this.data.choiceArray[3] == 0 && this.data.choiceArray[5] == 0) {
        this.setData({
          imgUrl: this.data.testResultList[3].imgUrl
        })
      } else if (this.data.choiceArray[3] == 0 && this.data.choiceArray[5] == 1) {
        this.setData({
          imgUrl: this.data.testResultList[0].imgUrl
        })
      } else if (this.data.choiceArray[3] == 0 && this.data.choiceArray[5] == 2) {
        this.setData({
          imgUrl: this.data.testResultList[2].imgUrl
        })
      }
      if (this.data.choiceArray[3] == 1 && this.data.choiceArray[5] == 0) {
        this.setData({
          imgUrl: this.data.testResultList[0].imgUrl
        })
      } else if (this.data.choiceArray[3] == 1 && this.data.choiceArray[5] == 1) {
        this.setData({
          imgUrl: this.data.testResultList[2].imgUrl
        })
      } else if (this.data.choiceArray[3] == 1 && this.data.choiceArray[5] == 2) {
        this.setData({
          imgUrl: this.data.testResultList[1].imgUrl
        })
      }
      if (this.data.choiceArray[3] == 2 && this.data.choiceArray[5] == 0) {
        this.setData({
          imgUrl: this.data.testResultList[2].imgUrl
        })
      } else if (this.data.choiceArray[3] == 2 && this.data.choiceArray[5] == 1) {
        this.setData({
          imgUrl: this.data.testResultList[1].imgUrl
        })
      } else if (this.data.choiceArray[3] == 2 && this.data.choiceArray[5] == 2) {
        this.setData({
          imgUrl: this.data.testResultList[3].imgUrl
        })
      }
      if (this.data.choiceArray[3] == 3 && this.data.choiceArray[5] == 0) {
        this.setData({
          imgUrl: this.data.testResultList[1].imgUrl
        })
      } else if (this.data.choiceArray[3] == 3 && this.data.choiceArray[5] == 1) {
        this.setData({
          imgUrl: this.data.testResultList[3].imgUrl
        })
      } else if (this.data.choiceArray[3] == 3 && this.data.choiceArray[5] == 2) {
        this.setData({
          imgUrl: this.data.testResultList[0].imgUrl
        })
      }
      tt.redirectTo({
        url: `/pages/testResult/testResult?imgUrl=${this.data.imgUrl}&title=${this.data.title}`
      });
    } else if (this.data.title == "在相亲市场上你是什么级别") {
      var sum = 0;
      this.data.choiceArray.forEach((item, index) => {
        if (item == 0) {
          sum += 0
        } else if (item == 1) {
          sum += 1
        } else if (item == 2) {
          sum += 2
        }
      })
      if (sum >= 0 && sum <= 4) {
        this.setData({
          imgUrl: this.data.testResultList[0].imgUrl
        })
      } else if (sum >= 5 && sum <= 8) {
        this.setData({
          imgUrl: this.data.testResultList[1].imgUrl
        })
      } else if (sum >= 9 && sum <= 12) {
        this.setData({
          imgUrl: this.data.testResultList[2].imgUrl
        })
      }
      tt.redirectTo({
        url: `/pages/testResult/testResult?imgUrl=${this.data.imgUrl}&title=${this.data.title}`
      })
    } else if (this.data.title == "你是哪种超级英雄") {
      if (this.data.choiceArray[3] == 0 && this.data.choiceArray[5] == 0) {
        this.setData({
          imgUrl: this.data.testResultList[0].imgUrl
        })
      } else if (this.data.choiceArray[3] == 0 && this.data.choiceArray[5] == 1) {
        this.setData({
          imgUrl: this.data.testResultList[1].imgUrl
        })
      } else if (this.data.choiceArray[3] == 0 && this.data.choiceArray[5] == 2) {
        this.setData({
          imgUrl: this.data.testResultList[2].imgUrl
        })
      }
      if (this.data.choiceArray[3] == 1 && this.data.choiceArray[5] == 0) {
        this.setData({
          imgUrl: this.data.testResultList[1].imgUrl
        })
      } else if (this.data.choiceArray[3] == 1 && this.data.choiceArray[5] == 1) {
        this.setData({
          imgUrl: this.data.testResultList[2].imgUrl
        })
      } else if (this.data.choiceArray[3] == 1 && this.data.choiceArray[5] == 2) {
        this.setData({
          imgUrl: this.data.testResultList[3].imgUrl
        })
      }
      if (this.data.choiceArray[3] == 2 && this.data.choiceArray[5] == 0) {
        this.setData({
          imgUrl: this.data.testResultList[2].imgUrl
        })
      } else if (this.data.choiceArray[3] == 2 && this.data.choiceArray[5] == 1) {
        this.setData({
          imgUrl: this.data.testResultList[3].imgUrl
        })
      } else if (this.data.choiceArray[3] == 2 && this.data.choiceArray[5] == 2) {
        this.setData({
          imgUrl: this.data.testResultList[0].imgUrl
        })
      }
      if (this.data.choiceArray[3] == 3 && this.data.choiceArray[5] == 0) {
        this.setData({
          imgUrl: this.data.testResultList[3].imgUrl
        })
      } else if (this.data.choiceArray[3] == 3 && this.data.choiceArray[5] == 1) {
        this.setData({
          imgUrl: this.data.testResultList[0].imgUrl
        })
      } else if (this.data.choiceArray[3] == 3 && this.data.choiceArray[5] == 2) {
        this.setData({
          imgUrl: this.data.testResultList[1].imgUrl
        })
      }
      tt.redirectTo({
        url: `/pages/testResult/testResult?imgUrl=${this.data.imgUrl}&title=${this.data.title}`
      });
    } else if (this.data.title == "手机号码运势测评") {
      console.log(11111)
    } else {
      if (this.data.choiceArray[this.data.choiceArray.length - 1] == 0) {
        this.setData({
          imgUrl: this.data.testResultList[0].imgUrl
        })
      } else if (this.data.choiceArray[this.data.choiceArray.length - 1] == 1) {
        this.setData({
          imgUrl: this.data.testResultList[1].imgUrl
        })
      } else if (this.data.choiceArray[this.data.choiceArray.length - 1] == 2) {
        this.setData({
          imgUrl: this.data.testResultList[2].imgUrl
        })
      } else if (this.data.choiceArray[this.data.choiceArray.length - 1] == 3) {
        this.setData({
          imgUrl: this.data.testResultList[3].imgUrl
        })
      }
      tt.redirectTo({
        url: `/pages/testResult/testResult?imgUrl=${this.data.imgUrl}&testResultBg=${this.data.testResultBg}&title=${this.data.title}`
      });
    }

    // tuiwa.getAdEvent("videoStart")
    // tuiwa.playAd();
  },
  closeAdFunction() {
    // console.log("视频观看完成", this)
    // this.setData({
    //   lookResultLayer: false
    // })
    // console.log(this.data.title)
    // console.log("单选:", this.data.choiceArray)

    // console.log(this.data.testResultList)

    // if (this.data.title == "2021你的精神图腾是什么？") {
    //   if (this.data.choiceArray[0] === 0) {
    //     this.setData({
    //       imgUrl: this.data.testResultList[0].imgUrl
    //     })
    //   } else if (this.data.choiceArray[0] === 1) {
    //     this.setData({
    //       imgUrl: this.data.testResultList[1].imgUrl
    //     })
    //   } else if (this.data.choiceArray[0] === 2) {
    //     this.setData({
    //       imgUrl: this.data.testResultList[2].imgUrl
    //     })
    //   } else if (this.data.choiceArray[0] === 3) {
    //     this.setData({
    //       imgUrl: this.data.testResultList[3].imgUrl
    //     })
    //   } else if (this.data.choiceArray[0] === 4) {
    //     this.setData({
    //       imgUrl: this.data.testResultList[4].imgUrl
    //     })
    //   }
    //   tt.redirectTo({
    //     url: `/pages/testResult/testResult?imgUrl=${this.data.imgUrl}&testResultBg=${this.data.testResultBg}&title=${this.data.title}`
    //   });
    // } else if (this.data.title == "2021年你会发生的5件事？") {
    //   if (this.data.choiceArray[3] === 0) {
    //     this.setData({
    //       imgUrl: this.data.testResultList[3].imgUrl
    //     })
    //   } else if (this.data.choiceArray[3] === 2) {
    //     this.setData({
    //       imgUrl: this.data.testResultList[4].imgUrl
    //     })
    //   } else if (this.data.choiceArray[3] === 1) {
    //     this.setData({
    //       imgUrl: this.data.testResultList[1].imgUrl
    //     })
    //   } else if (this.data.choiceArray[5] === 1) {
    //     this.setData({
    //       imgUrl: this.data.testResultList[2].imgUrl
    //     })
    //   } else if (this.data.choiceArray[5] === 0) {
    //     this.setData({
    //       imgUrl: this.data.testResultList[0].imgUrl
    //     })
    //   }
    //   tt.redirectTo({
    //     url: `/pages/testResult/testResult?imgUrl=${this.data.imgUrl}&testResultBg=${this.data.testResultBg}&title=${this.data.title}`
    //   });
    // }
    // else if (this.data.title == "2021你会以什么方式陪父母？" || this.data.title == "2021有多少人关心你？") {
    //   if (this.data.choiceArray[2] == 0) {
    //     this.setData({
    //       imgUrl: this.data.testResultList[0].imgUrl
    //     })
    //   } else if (this.data.choiceArray[2] == 1) {
    //     this.setData({
    //       imgUrl: this.data.testResultList[1].imgUrl
    //     })
    //   } else if (this.data.choiceArray[2] == 2) {
    //     this.setData({
    //       imgUrl: this.data.testResultList[2].imgUrl
    //     })
    //   } else if (this.data.choiceArray[2] == 3) {
    //     this.setData({
    //       imgUrl: this.data.testResultList[2].imgUrl
    //     })
    //   }
    //   tt.redirectTo({
    //     url: `/pages/testResult/testResult?imgUrl=${this.data.imgUrl}&testResultBg=${this.data.testResultBg}&title=${this.data.title}`
    //   });
    // } else if (this.data.title == "2021正能量测试") {
    //   var sum = 0;
    //   this.data.choiceArray.forEach((item, index) => {
    //     if (item == 0) {
    //       item = 2
    //     } else if (item == 1) {
    //       item = 1
    //     } else if (item == 2) {
    //       item = 0
    //     }
    //     sum += item;
    //   })
    //   console.log("正能量测试:", sum)

    //   if (sum >= 12 && sum <= 16) {
    //     this.setData({
    //       imgUrl: this.data.testResultList[0].imgUrl
    //     })
    //   } else if (sum >= 6 && sum <= 11) {
    //     this.setData({
    //       imgUrl: this.data.testResultList[1].imgUrl
    //     })
    //   } else if (sum >= 0 && sum <= 5) {
    //     this.setData({
    //       imgUrl: this.data.testResultList[2].imgUrl
    //     })
    //   }
    //   tt.redirectTo({
    //     url: `/pages/testResult/testResult?imgUrl=${this.data.imgUrl}&testResultBg=${this.data.testResultBg}&title=${this.data.title}`
    //   })
    // } else if (this.data.title == "2021春晚测试") {
    //   console.log(this.data.timu)
    //   this.data.choiceArray.forEach((item, index) => {
    //     var timu = this.data.timu[index]
    //     let wenti = timu.options[item]
    //     console.log("timu:", timu)
    //     console.log("wenti:", wenti)
    //     var trueAnswers = this.data.cunwanAnswer
    //     trueAnswers.push(wenti.flag)
    //     this.setData({
    //       cunwanAnswer: trueAnswers
    //     })
    //   })
    //   var trues = this.data.authenticAnswers
    //   this.data.cunwanAnswer.forEach((v, i) => {
    //     if (v) {
    //       trues.push(v)
    //     }
    //   })
    //   this.setData({
    //     authenticAnswers: trues
    //   })
    //   if (this.data.authenticAnswers.length >= 0 && this.data.authenticAnswers.length <= 3) {
    //     this.setData({
    //       imgUrl: this.data.testResultList[0].imgUrl
    //     })
    //   } else if (this.data.authenticAnswers.length >= 4 && this.data.authenticAnswers.length <= 6) {
    //     this.setData({
    //       imgUrl: this.data.testResultList[1].imgUrl
    //     })
    //   } else if (this.data.authenticAnswers.length == 7) {
    //     this.setData({
    //       imgUrl: this.data.testResultList[2].imgUrl
    //     })
    //   }

    //   tt.redirectTo({
    //     url: `/pages/testResult/testResult?imgUrl=${this.data.imgUrl}&testResultBg=${this.data.testResultBg}&title=${this.data.title}`
    //   })
    // } else if (this.data.title == "智商测试题") {
    //   var sum1 = 0;
    //   this.data.choiceArray.forEach((item, index) => {
    //     if (index >= 0 && index <= 3) {
    //       var timu = this.data.timu[index]
    //       let wenti = timu.options[item];
    //       if (wenti.flag) {
    //         sum1 += 4;
    //       }
    //     } else if (index >= 4 && index <= 7) {
    //       var timu = this.data.timu[index]
    //       let wenti = timu.options[item];
    //       if (wenti.flag) {
    //         sum1 += 5;
    //       }
    //     } else if (index == 8) {
    //       var timu = this.data.timu[index + 1]
    //       let wenti = timu.options[item];
    //       if (wenti.flag) {
    //         sum1 += 8;
    //       }
    //     }
    //   })
    //   console.log("sum1的值是:", sum1)

    //   var sum2 = 0
    //   var trueAnswers = []
    //   this.data.timu.forEach((item, index) => {
    //     if (index == 8) {
    //       item.options.forEach((v, i) => {
    //         if (v.leap == "A" && v.flag == true) {
    //           trueAnswers.push(0)
    //         } else if (v.leap == "B" && v.flag == true) {
    //           trueAnswers.push(1)
    //         } else if (v.leap == "C" && v.flag == true) {
    //           trueAnswers.push(2)
    //         } else if (v.leap == "D" && v.flag == true) {
    //           trueAnswers.push(3)
    //         }
    //       })
    //     }
    //   })
    //   // console.log("trueAnswers的值是:",trueAnswers)

    //   // console.log("multipleChoiceArr的值222是:", this.data.multipleChoiceArr)
    //   if (trueAnswers.sort().toString() == this.data.multipleChoiceArr.sort().toString()) {
    //     sum2 += 8
    //   } else {
    //     sum2 += 0
    //   }
    //   console.log("sum2的值是：", sum2)

    //   var sums = sum1 + sum2
    //   console.log("sums总的值是：", sums)
    //   tt.redirectTo({
    //     url: `/pages/testResult/testResult?sums=${sums}&testResultBg=${this.data.testResultBg}&title=${this.data.title}`
    //   });

    // } else if (this.data.title == "情商测试题") {
    //   var sums = 0;
    //   if (this.data.choiceArray[0] == 0 || this.data.choiceArray[0] == 1 || this.data.choiceArray[0] == 2) {
    //     sums += 20
    //   } else if (this.data.choiceArray[0] == 3) {
    //     sums += 0
    //   }
    //   if (this.data.choiceArray[1] == 0 || this.data.choiceArray[1] == 2 || this.data.choiceArray[1] == 3) {
    //     sums += 20
    //   } else if (this.data.choiceArray[1] == 1) {
    //     sums += 0
    //   }
    //   if (this.data.choiceArray[2] == 0 || this.data.choiceArray[2] == 2) {
    //     sums += 20
    //   } else if (this.data.choiceArray[2] == 1 || this.data.choiceArray[2] == 3) {
    //     sums += 0
    //   }
    //   if (this.data.choiceArray[3] == 0 || this.data.choiceArray[3] == 1 || this.data.choiceArray[3] == 3) {
    //     sums += 0
    //   } else if (this.data.choiceArray[3] == 2) {
    //     sums += 20
    //   }
    //   if (this.data.choiceArray[4] == 0 || this.data.choiceArray[4] == 1 || this.data.choiceArray[4] == 3) {
    //     sums += 0
    //   } else if (this.data.choiceArray[4] == 2) {
    //     sums += 20
    //   }
    //   if (this.data.choiceArray[5] == 0) {
    //     sums += 0
    //   } else if (this.data.choiceArray[5] == 1 || this.data.choiceArray[5] == 2) {
    //     sums += 5
    //   } else if (this.data.choiceArray[5] == 3) {
    //     sums += 20
    //   }
    //   if (this.data.choiceArray[6] == 1 || this.data.choiceArray[6] == 2 || this.data.choiceArray[6] == 3) {
    //     sums += 0
    //   } else if (this.data.choiceArray[6] == 0) {
    //     sums += 20
    //   }
    //   if (this.data.choiceArray[7] == 0 || this.data.choiceArray[7] == 2 || this.data.choiceArray[7] == 3) {
    //     sums += 0
    //   } else if (this.data.choiceArray[7] == 1) {
    //     sums += 20
    //   }
    //   if (this.data.choiceArray[8] == 0 || this.data.choiceArray[8] == 2) {
    //     sums += 0
    //   } else if (this.data.choiceArray[8] == 1) {
    //     sums += 5
    //   } else if (this.data.choiceArray[8] == 3) {
    //     sums += 20
    //   }
    //   if (this.data.choiceArray[9] == 0 || this.data.choiceArray[9] == 2 || this.data.choiceArray[9] == 3) {
    //     sums += 0
    //   } else if (this.data.choiceArray[9] == 1) {
    //     sums += 20
    //   }
    //   console.log("sums的值是:", sums)

    //   tt.redirectTo({
    //     url: `/pages/testResult/testResult?sums=${sums}&testResultBg=${this.data.testResultBg}&title=${this.data.title}`
    //   });

    // } else {
    //   if (this.data.choiceArray[this.data.choiceArray.length - 1] == 0) {
    //     this.setData({
    //       imgUrl: this.data.testResultList[0].imgUrl
    //     })
    //   } else if (this.data.choiceArray[this.data.choiceArray.length - 1] == 1) {
    //     this.setData({
    //       imgUrl: this.data.testResultList[1].imgUrl
    //     })
    //   } else if (this.data.choiceArray[this.data.choiceArray.length - 1] == 2) {
    //     this.setData({
    //       imgUrl: this.data.testResultList[2].imgUrl
    //     })
    //   } else if (this.data.choiceArray[this.data.choiceArray.length - 1] == 3) {
    //     this.setData({
    //       imgUrl: this.data.testResultList[3].imgUrl
    //     })
    //   }
    //   tt.redirectTo({
    //     url: `/pages/testResult/testResult?imgUrl=${this.data.imgUrl}&testResultBg=${this.data.testResultBg}&title=${this.data.title}`
    //   });
    // }
    // tuiwa.getAdEvent("videoEnd")
  },
  cancelAdFunction() {
    console.log('用户取消')
  },
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function (options) {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})